class Shop::ShopersController < ShopController
  skip_before_action :authenticate_shoper!, only: [:new, :create]

  def new
    @shoper = Shoper.new
  end
  
  def create
    shoper = Shoper.new shoper_params
    if shoper.save
      redirect_to shop_login_path, notice: "创建成功,请登录."
    else
      redirect_to shop_register_path, notice: "创建学校失败,请联系客服."
    end
  end

  def edit
    @shoper = current_shoper
  end

  def update
    @shoper = current_shoper
    if @shoper.update shoper_params
      redirect_to edit_shop_shoper_path(@shoper), notice: "更新成功！"
    else
      redirect_to edit_shop_shoper_path(@shoper), notice: "更新失败！"
    end
  end

  private

  def shoper_params
    params.require(:shoper).permit(:name, :nickname, :password, :avatar)
  end
end
